package link.anyauto.fsmgr.biz.clientpofolio;

import android.databinding.BaseObservable;
import android.databinding.Bindable;
import android.util.Log;
import android.util.StringBuilderPrinter;
import android.widget.RadioButton;

import java.util.ArrayList;
import java.util.List;

import link.anyauto.fsmgr.BR;
import link.anyauto.fsmgr.FsmgrApp;
import link.anyauto.fsmgr.R;
import link.anyauto.fsmgr.vo.SpinnerItemVO;
import me.tatarka.bindingcollectionadapter.ItemView;

/**
 * Created by discotek on 16-7-19.
 */

public class ClientPortfolioVM extends BaseObservable {

    @Bindable
    public String getName() {
        return null;
    }

    @Bindable
    public String getMobile() {
        return null;
    }

    @Bindable
    public boolean isReplacement() {
        return replacement;
    }

    public void setReplacement(boolean replacement) {
        if(this.replacement != replacement) {
            this.replacement = replacement;
            notifyPropertyChanged(BR.replacement);
        }
    }

    @Bindable
    public boolean isAssess() {
        return assess;
    }

    public void setAssess(boolean assess) {
        if(this.assess != assess) {
            this.assess = assess;
            notifyPropertyChanged(BR.assess);
        }
    }

    @Bindable
    public boolean isInsurance() {
        return insurance;
    }

    public void setInsurance(boolean insurance) {
        if(this.insurance != insurance) {
            this.insurance = insurance;
            notifyPropertyChanged(BR.insurance);
        }
    }

    @Bindable
    public boolean isRegister() {
        return register;
    }

    public void setRegister(boolean register) {
        if(this.register != register) {
            this.register = register;
            notifyPropertyChanged(BR.register);
        }
    }

    @Bindable
    public boolean isMale() {
        return male;
    }

    public void setMale(boolean male) {
        if(this.male != male) {
            this.male = male;
            notifyPropertyChanged(BR.male);
        }
    }

    public String[] getConcernLabels() {
        if(concerns == null) {
            concerns = FsmgrApp.getStringArrRes(R.array.port_concerns);
            concernSelections = new boolean[concerns.length];
        }
        return concerns;
    }

    @Bindable
    public boolean[] getConcernSelections() {
        if(concernSelections == null) {
            getConcernLabels();
        }
        return concernSelections;
    }

    public void setConcernSelections(boolean selected, int position) {
        if(concernSelections[position] != selected) {
            concernSelections[position] = selected;
            notifyPropertyChanged(BR.concernSelections);
        }
    }

    @Bindable
    public boolean isDisplay() {
        return display;
    }

    public void setDisplay(boolean display) {
        if(this.display != display) {
            this.display = display;
            notifyPropertyChanged(BR.display);
        }
    }

    @Bindable
    public boolean isTryDrive() {
        return tryDrive;
    }

    public void setTryDrive(boolean tryDrive) {
        if(this.tryDrive != tryDrive) {
            this.tryDrive = tryDrive;
            notifyPropertyChanged(BR.tryDrive);
        }
    }

    @Bindable
    public List<SpinnerItemVO> getCarNames() {
        List<SpinnerItemVO> names = new ArrayList<>();
        names.add(new SpinnerItemVO("博越"));
        names.add(new SpinnerItemVO("远景"));
        names.add(new SpinnerItemVO("熊猫"));
        names.add(new SpinnerItemVO("博瑞"));
        names.add(new SpinnerItemVO("黑金刚"));
        names.add(new SpinnerItemVO("帝豪"));
        return names;
    }

    public ItemView spinnerView = ItemView.of(BR.item, R.layout.item_common_spinner);

    boolean replacement;
    boolean assess;
    boolean insurance;
    boolean register;
    boolean male;
    boolean display;
    boolean tryDrive;
    String[] concerns;
    boolean[] concernSelections;
}
